package org.jmsmith.utilities.io;

import org.junit.jupiter.api.Test;
import org.mockito.Mockito;

import java.io.*;
import java.util.zip.ZipOutputStream;

import static org.junit.jupiter.api.Assertions.*;
import static org.mockito.Mockito.*;

public class CompressorTest {

    @Test
    public void testCompressDirectory() throws IOException {
        // Create a temporary file and directory for testing
        var tempDir = new File("tempDir");
        tempDir.mkdir();
        var tempFile = new File(tempDir, "tempFile");
        tempFile.createNewFile();

        // Create a temporary output file
        var tempOutput = new File("tempOutput.zip");

        // Create a FileOutputStream and ZipOutputStream for the output file
        var fos = new FileOutputStream(tempOutput);
        var zipOut = new ZipOutputStream(fos);

        // Call the method to test
        Compressor.compressDirectory(tempDir, tempDir.getName(), zipOut);

        // Close the ZipOutputStream and FileOutputStream
        zipOut.close();
        fos.close();

        // Check that the output file exists and is not empty
        assertTrue(tempOutput.exists());
        assertTrue(tempOutput.length() > 0);

        // Clean up the temporary files
        tempFile.delete();
        tempDir.delete();
        tempOutput.delete();
    }
}
